from appium.webdriver.common.mobileby import MobileBy
from selenium.webdriver.support import expected_conditions
from selenium.webdriver.support.wait import WebDriverWait


class AddMemberPackage:
    def __init__(self,driver):
        self.driver = driver

    def non_auto_add_member(self):
        # 填入成员信息
        self.driver.find_element(MobileBy.XPATH,"//*[contains(@text,'手动输入')]").click()
        WebDriverWait(self.driver,10).until(
            expected_conditions.presence_of_element_located((MobileBy.XPATH,"//*[@text='必填']")))
        self.driver.find_element(MobileBy.XPATH,"//*[@text='必填']").send_keys("成员01")
        self.driver.find_element(MobileBy.XPATH, "//*[@text='手机号']").send_keys("12345678901")
        # 添加邮箱，注意页面有两个【选填】，找出class不同后使用 and 联合定位，这里用相对路径不好区分
        self.driver.find_element(MobileBy.XPATH, "//*[@text='选填' and @class='android.widget.EditText']").send_keys("58947458885@qq.com")
        # 取消发送邀请通知
        self.driver.find_element(MobileBy.XPATH, "//*[@text='保存后自动发送邀请通知']").click()
        # 保存
        self.driver.find_element(MobileBy.XPATH, "//*[@text='保存']").click()
